package com.demo.vueservice.service.impl;

import com.demo.vueservice.common.entity.User;
import com.demo.vueservice.repository.UserRepository;
import com.demo.vueservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserRepository userRepository;

    @Override
    public User saveUser(User user) {
        return userRepository.save(user);
    }

    @Override
    public User checkLogin(String name, String password) {
        return userRepository.findFirstByNameAndPassword(name,password);
    }

    @Override
    public List<User> findUsers() {
        return userRepository.findAll();
    }
}
